package com.yllt4cloud.common.ddbase.util.crypto;

import com.yllt4cloud.common.ddbase.util.Base64Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.charset.StandardCharsets;

/**
 *
 * @author Administrator
 */
public class Base64Crypto implements ICrypto{
    private  static final Logger LOGGER = LoggerFactory.getLogger(Base64Crypto.class);

    @Override
    public String decrypt(String content, String key) {
        return Base64Utils.decodeToString(content, StandardCharsets.UTF_8);
    }

    @Override
    public String encrypt(String content, String key) {
        return Base64Utils.encode(content.getBytes());
    }
    
    public static void main(String[] args) {
    	Base64Crypto base64Crypto = new Base64Crypto();
		System.out.println(base64Crypto.encrypt("{\"token\":\"123456\",\"user\":\"123456\"}","123456"));
		System.out.println(base64Crypto.decrypt("eyJ0b2tlbiI6IjEyMzQ1NiIsInVzZXIiOiIxMjM0NTYifQ==", "123456"));
		
	}
}
